package com.bort.system.controller.admin;

import com.bort.system.model.Menu;
import com.bort.system.model.User;
import com.bort.system.service.TDeskService;
import com.bort.system.service.UserService;
import com.bort.system.utils.Result;
import org.apache.shiro.SecurityUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/admin")
public class AdminIndexController {

    @Resource
    UserService userService;

    @Resource
    TDeskService deskService;

    @RequestMapping("/menus")
    public Result menus() {
        Result result = new Result();
        User user = (User) SecurityUtils.getSubject().getPrincipal();
        List<Menu> menus = userService.selectPromisedMenus(user.getId());
        result.setData(menus);
        return result;
    }

    @RequestMapping(value = "/main/top",method = RequestMethod.POST)
    public Result topData(@RequestBody Map<String,Object> params){
       return deskService.countTopData(params);
    }

    @RequestMapping(value = "/main/line",method = RequestMethod.POST)
    public Result lineData(@RequestBody Map<String,Object> params){
        return deskService.countLineData(params);
    }
}
